package com.wlyuan.open.domain.api.service;

import com.wlyuan.open.domain.api.assembler.OpenApiLogAssembler;
import com.wlyuan.open.domain.api.respository.OpenApiLogRepository;
import com.wlyuan.open.dto.api.OpenApiLogCreationDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.var;
import org.springframework.stereotype.Service;

/**
 * @author lijing
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class OpenApiLogService {
    private final OpenApiLogRepository openApiLogRepository;

    public void add(OpenApiLogCreationDTO creation) {
        try {
            var openApiLog = OpenApiLogAssembler.assemble(creation);
            openApiLogRepository.save(openApiLog);
        } catch (Exception e) {
            logger.error("添加访问日志失败：{}", e);
        }
    }
}
